package com.ruoyi.ebike.service.impl;

import java.util.List;

import com.ruoyi.ebike.utils.GiftCardCodeUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.ebike.mapper.GiftCardMapper;
import com.ruoyi.ebike.domain.GiftCard;
import com.ruoyi.ebike.service.IGiftCardService;

/**
 * 礼品卡配置Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-01-09
 */
@Service
public class GiftCardServiceImpl implements IGiftCardService 
{
    @Autowired
    private GiftCardMapper giftCardMapper;

    /**
     * 查询礼品卡配置
     * 
     * @param id 礼品卡配置主键
     * @return 礼品卡配置
     */
    @Override
    public GiftCard selectGiftCardById(Long id)
    {
        return giftCardMapper.selectGiftCardById(id);
    }

    /**
     * 查询礼品卡配置列表
     * 
     * @param giftCard 礼品卡配置
     * @return 礼品卡配置
     */
    @Override
    public List<GiftCard> selectGiftCardList(GiftCard giftCard)
    {
        return giftCardMapper.selectGiftCardList(giftCard);
    }

    /**
     * 新增礼品卡配置
     * 
     * @param giftCard 礼品卡配置
     * @return 结果
     */
    @Override
    public int insertGiftCard(GiftCard giftCard)
    {
        giftCard.setCode(GiftCardCodeUtils.generateVerificationCode());
        giftCard.setStatus(0);  //未使用
        return giftCardMapper.insertGiftCard(giftCard);
    }

    /**
     * 修改礼品卡配置
     * 
     * @param giftCard 礼品卡配置
     * @return 结果
     */
    @Override
    public int updateGiftCard(GiftCard giftCard)
    {
        return giftCardMapper.updateGiftCard(giftCard);
    }

    /**
     * 批量删除礼品卡配置
     * 
     * @param ids 需要删除的礼品卡配置主键
     * @return 结果
     */
    @Override
    public int deleteGiftCardByIds(Long[] ids)
    {
        return giftCardMapper.deleteGiftCardByIds(ids);
    }

    /**
     * 删除礼品卡配置信息
     * 
     * @param id 礼品卡配置主键
     * @return 结果
     */
    @Override
    public int deleteGiftCardById(Long id)
    {
        return giftCardMapper.deleteGiftCardById(id);
    }
}
